home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Utilities / DreamCDGuide / sources / Dreamcat.c < prev    next >
C/C++ Source or Header  |  2000-04-11  |  9KB  |  288 lines

  1. /****************************************************************
  2.    This file was created automatically by `FlexCat 2.1'
  3.    from "dreamcdguide.cd".
  4.  
  5.    Do NOT edit by hand!
  6. ****************************************************************/
  7.  
  8. /****************************************************************
  9.     This file uses the auto initialization possibilities of
  10.     Dice, gcc and SAS/C, respectively.
  11.  
  12.     Dice does this by using the keywords __autoinit and
  13.     __autoexit, SAS uses names beginning with _STI or
  14.     _STD, respectively. gcc uses the asm() instruction,
  15.     to emulate C++ constructors and destructors.
  16.  
  17.     Using this file you don't have *all* possibilities of
  18.     the locale.library. (No Locale or Language arguments are
  19.     supported when opening the catalog. However, these are
  20.     *very* rarely used, so this should be sufficient for most
  21.     applications.
  22. ****************************************************************/
  23.  
  24.  
  25. /*
  26.     Include files and compiler specific stuff
  27. */
  28. #include <exec/memory.h>
  29. #include <libraries/locale.h>
  30. #include <libraries/iffparse.h>
  31.  
  32. #include <proto/exec.h>
  33. #include <proto/dos.h>
  34. #include <proto/locale.h>
  35. #include <proto/utility.h>
  36. #include <proto/iffparse.h>
  37.  
  38. #include <stdlib.h>
  39. #include <string.h>
  40.  
  41.  
  42.  
  43. #include "dreamcat.h"
  44.  
  45.  
  46. /*
  47.     Variables
  48. */
  49. struct FC_String dreamcdguide_Strings[59] = {
  50.     { (STRPTR) "\000Drawer", 1 },
  51.     { (STRPTR) "\000Parent...", 2 },
  52.     { (STRPTR) "\000Change Dir", 3 },
  53.     { (STRPTR) "\000Project", 4 },
  54.     { (STRPTR) "?\000About...", 5 },
  55.     { (STRPTR) "M\000About MUI", 6 },
  56.     { (STRPTR) "Q\000Quit", 7 },
  57.     { (STRPTR) "\000Settings", 8 },
  58.     { (STRPTR) "\000MUI...", 9 },
  59.     { (STRPTR) "\000Tools", 10 },
  60.     { (STRPTR) "\000LHA Output", 11 },
  61.     { (STRPTR) "\000Log File", 12 },
  62.     { (STRPTR) "\000Search", 13 },
  63.     { (STRPTR) "MUI Front-End for Aminet CDs", 14 },
  64.     { (STRPTR) "Emilie, I love you !", 15 },
  65.     { (STRPTR) "Drawer:", 16 },
  66.     { (STRPTR) "Enter here the name\nof the dir to display...", 17 },
  67.     { (STRPTR) "Please choose a directory...", 18 },
  68.     { (STRPTR) "Directories", 19 },
  69.     { (STRPTR) "Choose a directory\nto display its contents...", 20 },
  70.     { (STRPTR) "Archives", 21 },
  71.     { (STRPTR) "Archives in the current Dir...", 22 },
  72.     { (STRPTR) "Options:", 23 },
  73.     { (STRPTR) "_Parent", 24 },
  74.     { (STRPTR) "_Info", 25 },
  75.     { (STRPTR) "_Extract", 26 },
  76.     { (STRPTR) "_Quit", 27 },
  77.     { (STRPTR) "Quit DreamCDGuide...", 28 },
  78.     { (STRPTR) "Description of the \nSelected File...", 29 },
  79.     { (STRPTR) "Unable to create the application.", 30 },
  80.     { (STRPTR) "DreamCDGuide has detected \n the insertion of the CD:", 31 },
  81.     { (STRPTR) "Continue ?", 32 },
  82.     { (STRPTR) "Continue !", 33 },
  83.     { (STRPTR) "Quit...", 34 },
  84.     { (STRPTR) "Ok !", 35 },
  85.     { (STRPTR) "Go to Parent dir...", 36 },
  86.     { (STRPTR) "Extracts the selected file...", 37 },
  87.     { (STRPTR) "Shows contents of the selected archive", 38 },
  88.     { (STRPTR) "Where to extract", 39 },
  89.     { (STRPTR) "Extract", 40 },
  90.     { (STRPTR) "To", 41 },
  91.     { (STRPTR) "Couldn't lock", 42 },
  92.     { (STRPTR) "MUI FrontEnd for Aminet CDs", 43 },
  93.     { (STRPTR) "File Selected:", 44 },
  94.     { (STRPTR) "No File Selected !", 45 },
  95.     { (STRPTR) "DreamCDGuide haven't detected", 46 },
  96.     { (STRPTR) "The insertion of any CD...", 47 },
  97.     { (STRPTR) "Do you wish to wait ?", 48 },
  98.     { (STRPTR) "Wait", 49 },
  99.     { (STRPTR) "DreamCDGuide cannot be started Twice !", 50 },
  100.     { (STRPTR) "No !", 51 },
  101.     { (STRPTR) "\033c** No File Selected !**", 52 },
  102.     { (STRPTR) "\033c**Description not Available !**", 53 },
  103.     { (STRPTR) "Oh, Sh*** !", 54 },
  104.     { (STRPTR) "Operation Aborded !", 55 },
  105.     { (STRPTR) "Ok...", 56 },
  106.     { (STRPTR) "\033cDiskchange...\nPress Ok then Change CD\n\n(DreamCDGuide will autodetect the diskchange...)", 57 },
  107.     { (STRPTR) "Operation Canceled !", 58 },
  108.     { (STRPTR) "\033c\033bShortCuts:\n----------\033n\n\033l\0333F1\0330-Extracts the Selected File\n\0333F2-\0330Display contents of the current Archive\n\0333F10\0330-Diskchange (Autolock)", 59 }
  109. };
  110.  
  111. STATIC struct Catalog *dreamcdguideCatalog = NULL;
  112. #ifdef LOCALIZE_V20
  113. STATIC STRPTR dreamcdguideStrings = NULL;
  114. STATIC ULONG dreamcdguideStringsSize;
  115. #endif
  116.  
  117.  
  118. #if defined(_DCC)
  119. STATIC __autoexit VOID _STDClosedreamcdguideCatalog(VOID)
  120. #elif defined(__SASC)
  121. VOID _STDClosedreamcdguideCatalog(VOID)
  122. #elif defined(__GNUC__)
  123. STATIC VOID _STDClosedreamcdguideCatalog(VOID)
  124. #else
  125. VOID ClosedreamcdguideCatalog(VOID)
  126. #endif
  127.  
  128. {
  129.     if (dreamcdguideCatalog) {
  130.     CloseCatalog(dreamcdguideCatalog);
  131.     }
  132. #ifdef LOCALIZE_V20
  133.     if (dreamcdguideStrings) {
  134.     FreeMem(dreamcdguideStrings, dreamcdguideStringsSize);
  135.     }
  136. #endif
  137. }
  138.  
  139.  
  140. #if defined(_DCC)
  141. STATIC __autoinit VOID _STIOpendreamcdguideCatalog(VOID)
  142. #elif defined(__SASC)
  143. VOID _STIOpendreamcdguideCatalog(VOID)
  144. #elif defined(__GNUC__)
  145. VOID _STIOpendreamcdguideCatalog(VOID)
  146. #else
  147. VOID OpendreamcdguideCatalog(VOID)
  148. #endif
  149.  
  150. {
  151.     if (LocaleBase) {
  152.     if ((dreamcdguideCatalog = OpenCatalog(NULL, (STRPTR) "dreamcdguide.catalog",
  153.                      OC_BuiltInLanguage, "english",
  154.                      OC_Version, 0,
  155.                      TAG_DONE))) {
  156.         struct FC_String *fc;
  157.         int i;
  158.  
  159.         for (i = 0, fc = dreamcdguide_Strings;  i < 59;  i++, fc++) {
  160.          fc->msg = GetCatalogStr(dreamcdguideCatalog, fc->id, (STRPTR) fc->msg);
  161.         }
  162.     }
  163.     }
  164. }
  165.  
  166. #if defined(__GNUC__)
  167. __asm ("  .text;  .stabs \"___CTOR_LIST__\",22,0,0,__STIOpendreamcdguideCatalog");
  168. __asm ("  .text;  .stabs \"___DTOR_LIST__\",22,0,0,__STDClosedreamcdguideCatalog");
  169. #endif
  170.  
  171.  
  172.  
  173. #ifdef LOCALIZE_V20
  174. VOID InitdreamcdguideCatalog(STRPTR language)
  175.  
  176. {
  177.     struct IFFHandle *iffHandle;
  178.  
  179.     /*
  180.     **  Use iffparse.library only, if we need to.
  181.     */
  182.     if (LocaleBase  ||  !IFFParseBase  ||  !language  ||
  183.     Stricmp(language, "english") == 0) {
  184.     return;
  185.     }
  186.  
  187.     if ((iffHandle = AllocIFF())) {
  188.     char path[128]; /* Enough to hold 4 path items (dos.library 3.1)    */
  189.     strcpy(path, "PROGDIR:Catalogs");
  190.     AddPart((STRPTR) path, language, sizeof(path));
  191.     AddPart((STRPTR) path, "dreamcdguide.catalog", sizeof(path));
  192.     if (!(iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE))) {
  193.         strcpy(path, "LOCALE:Catalogs");
  194.         AddPart((STRPTR) path, language, sizeof(path));
  195.         AddPart((STRPTR) path, language, sizeof(path));
  196.         iffHandle->iff_Stream = Open((STRPTR) path, MODE_OLDFILE);
  197.     }
  198.  
  199.     if (iffHandle->iff_Stream) {
  200.         InitIFFasDOS(iffHandle);
  201.         if (!OpenIFF(iffHandle, IFFF_READ)) {
  202.         if (!PropChunk(iffHandle, MAKE_ID('C','T','L','G'),
  203.                    MAKE_ID('S','T','R','S'))) {
  204.             struct StoredProperty *sp;
  205.             int error;
  206.  
  207.             for (;;) {
  208.             if ((error = ParseIFF(iffHandle, IFFPARSE_STEP))
  209.                    ==  IFFERR_EOC) {
  210.                 continue;
  211.             }
  212.             if (error) {
  213.                 break;
  214.             }
  215.  
  216.             if ((sp = FindProp(iffHandle, MAKE_ID('C','T','L','G'),
  217.                        MAKE_ID('S','T','R','S')))) {
  218.                 /*
  219.                 **  Check catalog and calculate the needed
  220.                 **  number of bytes.
  221.                 **  A catalog string consists of
  222.                 **      ID (LONG)
  223.                 **      Size (LONG)
  224.                 **      Bytes (long word padded)
  225.                 */
  226.                 LONG bytesRemaining;
  227.                 LONG *ptr;
  228.  
  229.                 dreamcdguideStringsSize = 0;
  230.                 bytesRemaining = sp->sp_Size;
  231.                 ptr = (LONG *) sp->sp_Data;
  232.  
  233.                 while (bytesRemaining > 0) {
  234.                 LONG skipSize, stringSize;
  235.  
  236.                 ptr++;                  /*  Skip ID     */
  237.                 stringSize = *ptr++;
  238.                 skipSize = ((stringSize+3) >> 2);
  239.  
  240.                 dreamcdguideStringsSize += stringSize+1;  /*  NUL */
  241.                 bytesRemaining -= 8 + (skipSize << 2);
  242.                 ptr += skipSize;
  243.                 }
  244.  
  245.                 if (!bytesRemaining  &&
  246.                 (dreamcdguideStrings = AllocMem(dreamcdguideStringsSize, MEMF_ANY))) {
  247.                 STRPTR sptr;
  248.  
  249.                 bytesRemaining = sp->sp_Size;
  250.                 ptr = (LONG *) sp->sp_Data;
  251.                 sptr = dreamcdguideStrings;
  252.  
  253.                 while (bytesRemaining) {
  254.                     LONG skipSize, stringSize, id;
  255.                     struct FC_String *fc;
  256.                     int i;
  257.  
  258.                     id = *ptr++;
  259.                     stringSize = *ptr++;
  260.                     skipSize = ((stringSize+3) >> 2);
  261.  
  262.                     CopyMem(ptr, sptr, stringSize);
  263.                     bytesRemaining -= 8 + (skipSize << 2);
  264.                     ptr += skipSize;
  265.  
  266.                     for (i = 0, fc = dreamcdguide_Strings;  i < 59;  i++, fc++) {
  267.                     if (fc->id == id) {
  268.                         fc->msg = sptr;
  269.                     }
  270.                     }
  271.  
  272.                     sptr += stringSize;
  273.                     *sptr++ = '\0';
  274.                 }
  275.                 }
  276.                 break;
  277.             }
  278.             }
  279.         }
  280.         CloseIFF(iffHandle);
  281.         }
  282.         Close(iffHandle->iff_Stream);
  283.     }
  284.     FreeIFF(iffHandle);
  285.     }
  286. }
  287. #endif
  288.